package com.unnamed.collisions.logging;
import java.io.IOException;
import java.util.Formattable;
import java.util.logging.Formatter;
import java.util.logging.LogManager;
import java.util.logging.LogRecord;
import java.util.logging.Logger;


public class Log extends Formatter{
//	public static void main(String[] args) throws SecurityException, IOException {
//		LogManager.getLogManager().readConfiguration(Log.class.getResourceAsStream("/logging.properties"));
//		
//		Logger.getLogger("LogTest").info("Lalala");
//		Logger.getLogger("LogBlau").info("Lalala");
//	}

	static{
		try {
			LogManager.getLogManager().readConfiguration(Log.class.getResourceAsStream("/logging.properties"));
		} catch (SecurityException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	@Override
	public String format(LogRecord record) {
		return record.getMillis()+" ["+record.getLoggerName()+"] "+record.getMessage()+"\n";
	}
	
	public static void log(String id, String msg){
		Logger.getLogger(id).info(msg);
	}
	public static void log(String msg){
		//log("general",msg);
	}
	public static void log(Object o){
		log("general",o.toString());
	}
}
